﻿using System.Windows;

namespace ComicQ.View
{
    /// <summary>
    /// Interaction logic for StaffView.xaml
    /// </summary>
    public partial class StaffView
    {
        public StaffView()
        {
            InitializeComponent();

            //_staves = new List<Staff>
            //                  {
            //                      new Staff("10000", "Toz", "Mulyosari", "08123456789",
            //                          "tigor@gmail.com"),
            //                      new Staff("20000", "Reza", "Pucang Anom", "08123456789",
            //                          "nanda@gmail.com"),
            //                      new Staff("30000", "Yoga", "Wonokromo", "08123456789",
            //                          "alpin@yahoo.com")
            //                  };

            //dataGridStaff.ItemsSource = _staves;
        }

        private void ButtonAddClick(object sender, RoutedEventArgs e)
        {
            //var newWindow = new StaffEditorView(_staves);

            //if (newWindow.ShowDialog() != false)
            //{
            //}
            //else
            //{
            //    try
            //    {
            //        if (newWindow.Output == null)
            //            throw new NullReferenceException();

            //        _staves.Add(newWindow.Output);
            //        dataGridStaff.ItemsSource = null;
            //        dataGridStaff.ItemsSource = _staves;
            //    }
            //    catch (NullReferenceException)
            //    {
            //        MessageBox.Show("Tidak jadi menambah staff.");
            //    }
            //}
        }

        private void ButtonDeleteClick(object sender, RoutedEventArgs e)
        {
            //try
            //{
            //    if (dataGridStaff.SelectedItem == null)
            //        throw new NullReferenceException();

            //    _staves.RemoveAt(dataGridStaff.SelectedIndex);
            //    dataGridStaff.ItemsSource = null;
            //    dataGridStaff.ItemsSource = _staves;
            //}
            //catch (NullReferenceException)
            //{
            //    MessageBox.Show("Pilih yang mau didelete.");
            //}
        }

        private void ButtonEditClick(object sender, RoutedEventArgs e)
        {
            //try
            //{
            //    if (dataGridStaff.SelectedItem == null)
            //        throw new NullReferenceException();

            //    var newWindow = new StaffEditorView(_staves[dataGridStaff.SelectedIndex]);

            //    if (newWindow.ShowDialog() != false)
            //    {
            //    }
            //    else
            //    {
            //        try
            //        {
            //            if (newWindow.Output == null)
            //                throw new NullReferenceException();

            //            _staves.RemoveAt(dataGridStaff.SelectedIndex);
            //            _staves.Insert(dataGridStaff.SelectedIndex, newWindow.Output);
            //            dataGridStaff.ItemsSource = null;
            //            dataGridStaff.ItemsSource = _staves;
            //        }
            //        catch (NullReferenceException)
            //        {
            //            MessageBox.Show("Tidak jadi mengedit staff.");
            //        }
            //    }
            //}
            //catch (NullReferenceException)
            //{
            //    MessageBox.Show("Pilih yang mau diedit.");
            //}
        }
    }
}
